package com.talkweb.securitycamera.slice;

import com.talkweb.securitycamera.ResourceTable;
import com.talkweb.securitycamera.common.base.BaseAbilitySlice;
import com.talkweb.securitycamera.common.constans.FileType;
import com.talkweb.securitycamera.common.interfaces.dataprocess.FileCallback;
import com.talkweb.securitycamera.common.interfaces.dataprocess.IFileGet;
import com.talkweb.securitycamera.data.hadoopDB.HadoopDbProvider;
import com.talkweb.securitycamera.view.CameraView;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;

import java.io.File;

/**
 * @author : frank
 * @date : 2021/3/5 17:35
 */
public class TestAbilitySlice extends BaseAbilitySlice {

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_slice_test;
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);

        getWindow().setTransparent(true);

        CameraView cameraView = findComponent(ResourceTable.Id_cameraView);
        cameraView.setFileGet(type -> new File(getContext().getCacheDir(), "test.mp4"));
        cameraView.setFileGet(new HadoopDbProvider(getContext(), type1 -> {
        }));
        cameraView.setCameraConfiguredCallback(() -> cameraView.startCameraRecord());
        cameraView.startPreview();

        findComponent(ResourceTable.Id_button_take_picture).setClickedListener(component ->
                cameraView.takePicture());
    }
}
